<?php
class Table_export extends CI_Controller {
 
    function __construct()
    {
       
       parent::__construct();
	   $this->load->library('excel');
	   $this->load->library('To_excel');
	   //$this->load->model('product/table_export_model');	
        // Here you should add some sort of user validation
        // to prevent strangers from pulling your table data
    }
 
public  function excel_product($table)
{ 
$this->load->library('To_excel');
$this->db->select('product.name as Name,product.code as Code,category.name AS Category,company.name AS Company,product.purchase_price as PurchasePrice,product.selling_price as SellingPrice,product.opening_stock as OpeningStock,unit.name as Unit,product.alert_quantity as AlertQuantity');
$this->db->from('product', 'category','company','unit' );
$this->db->join('category', 'product.id_category = category.id' );
$this->db->join('company', 'product.id_company = company.id');
$this->db->join('unit', 'product.id_unit =unit.id');
$query = $this->db->get();
$this->to_excel->create_excel($query, 'Product'); // fi
}
public function excel_company($table)
{

$this->db->select('company.name as Name, company.description as Description');
$this->db->from('company' );
$query = $this->db->get();
$this->to_excel->create_excel($query, 'company_list'); // fi
}
public function excel_category($table)
{

$this->db->select('category.name as Name, category.description as Description');
$this->db->from('category' );
$query = $this->db->get();
$this->to_excel->create_excel($query, 'category_list'); // fi
}



}
?>